#include "Core/File/URI.h"
#include "Core/Log/LogManager.h"
#include "Core/Profile/CodeProfile.h"
#include "URITest.h"

const char * URITest::GetName() const
{
	return "[CORE] URI Test";
}

Core::error URITest::Create()
{
	if(Failed(UnitTest::Create()))
		return Core::errFailed;

	return Core::errOK;
}

Core::error URITest::Destroy()
{
	if(Failed(UnitTest::Destroy()))
		return Core::errFailed;

	return Core::errOK;
}

Core::error URITest::Execute()
{
	PROFILE(GetName());

	{
		Core::File::URI uri("toto/tata/titi.tutu");

		if(uri.GetPath() != "toto/tata/")
			return Core::errFailed;

		if(uri.GetFilename() != "titi")
			return Core::errFailed;

		if(uri.GetFileExtension() != ".tutu")
			return Core::errFailed;

	}

	{
		Core::File::URI uri("toto/tata/titi");

		if(uri.GetPath() != "toto/tata/")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

		if(uri.GetFilename() != "titi")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

		if(uri.GetFileExtension() != "")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

	}

	{
		Core::File::URI uri("titi.tutu");

		if(uri.GetPath() != "")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

		if(uri.GetFilename() != "titi")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

		if(uri.GetFileExtension() != ".tutu")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

	}

	{
		Core::File::URI uri("titi");

		if(uri.GetPath() != "")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

		if(uri.GetFilename() != "titi")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

		if(uri.GetFileExtension() != "")
		{
			LOG_INFO("FAILED");
			return Core::errFailed;
		}

	}

	return Core::errOK;
}
